package com.commonlover.controller;

import com.alibaba.fastjson.JSONObject;
import com.commonlover.result.PageVo;
import com.commonlover.result.WebResult;
import com.commonlover.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.LinkedHashMap;

@RestController
@RequestMapping("article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    /**
     * 根据用户ID查询所属文章
     * @return
     */
    @PostMapping("findArticleByAuthorIdAndPageParam")
    public WebResult<PageVo<LinkedHashMap<String,Object>>> findArticleByAuthorIdAndPageParam(@RequestBody JSONObject param) {
        return WebResult.<PageVo<LinkedHashMap<String,Object>>>builder()
                .code(200)
                .message(WebResult.REQUEST_STATUS_SUCCESS)
                .data(articleService.findArticleByAuthorIdAndPageParam(param))
                .build();
    }

}
